package com.example.hetong.controller;

// import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.hetong.entity.Contract;
import com.example.hetong.param.ContractParam;
import com.example.hetong.service.ContractService;
import com.example.common.vo.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * --- 业精于勤,荒于嬉 ---
 *
 * @author Song
 * @date 2024/9/11
 * @desc First
 */
@RestController
@RequestMapping("/attract/contract")
public class ContractController {

    @Resource
    private ContractService contractService;

    // @GetMapping("/page")
    // public IPage<Contract> page(ContractParam contractParam) {
    //     return contractService.page(contractParam);
    // }

    @GetMapping("/list")
    public R finaAll() {
        List<Contract> list = contractService.finaAll();
        return R.ok(list);
    }

    // 自定义分页
    // @GetMapping("/list")
    // public R findList(@RequestParam HashMap<String,String> map){
    //     int pageNum = Integer.parseInt(map.get("pageNum"));
    //     int pageSize = Integer.parseInt(map.get("pageSize"));
    //     PageHelper.startPage(pageNum,pageSize);
    //
    //     List<Contract> list = contractService.findByMap(map);
    //     PageInfo<Contract> info = new PageInfo<>(list);
    //     return R.ok(info);
    // }



    @GetMapping("/del")
    public R delById(int id){
        boolean isok = contractService.delete(id);
        return R.ok(isok);
    }

    @PostMapping("/add")
    public R addList(@RequestBody Contract contract) {
        boolean isOk = contractService.addList(contract);
        return R.ok(isOk);
    }

    @GetMapping("/find")
    public R findKuang() {
        List<String> list = contractService.findKuang();
        return R.ok(list);
    }

}
